package org.ru.mse10.cvis.entity.cv.custom.provider;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.ru.mse10.cvis.entity.util.Bidirectional;
import org.ru.mse10.cvis.entity.util.CustomFieldValueProviderType;

/**
 * The Class WSCustomFieldValueProvider.
 */
@Entity
@Table(name = "ws_custom_field_value_provider")
public class WSCustomFieldValueProvider extends CustomFieldValueProvider
		implements Bidirectional {

	/** The wsdl location. */
	private String wsdlLocation;

	/** The operation. */
	private String operation;

	/** The params. */
	private List<WSParam> params = new ArrayList<WSParam>();

	/**
	 * Gets the wsdl location.
	 * 
	 * @return the wsdl location
	 */
	public String getWsdlLocation() {
		return wsdlLocation;
	}

	/**
	 * Sets the wsdl location.
	 * 
	 * @param wsdlLocation
	 *            the new wsdl location
	 */
	public void setWsdlLocation(String wsdlLocation) {
		this.wsdlLocation = wsdlLocation;
	}

	/**
	 * Gets the operation.
	 * 
	 * @return the operation
	 */
	public String getOperation() {
		return operation;
	}

	/**
	 * Sets the operation.
	 * 
	 * @param operation
	 *            the new operation
	 */
	public void setOperation(String operation) {
		this.operation = operation;
	}

	/**
	 * Gets the params.
	 * 
	 * @return the params
	 */
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "provider", orphanRemoval = true)
	public List<WSParam> getParams() {
		return params;
	}

	/**
	 * Sets the params.
	 * 
	 * @param params
	 *            the new params
	 */
	public void setParams(List<WSParam> params) {
		this.params = params;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.ru.mse10.cvis.entity.cv.custom.provider.CustomFieldValueProvider#
	 * type()
	 */
	@Override
	public CustomFieldValueProviderType type() {
		return CustomFieldValueProviderType.WS;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.ru.mse10.cvis.entity.util.Bidirectional#initializeBidirectionalReferences
	 * ()
	 */
	@Override
	public void initializeBidirectionalReferences() {
		for (WSParam param : getParams()) {
			param.setProvider(this);
		}
	}

}
